package com.huike.business.service.impl;


import com.huike.business.domain.TbBusiness;
import com.huike.business.domain.TbBusinessTrackRecord;
import com.huike.business.domain.vo.BusinessTrackVo;
import com.huike.business.mapper.TbBusinessTrackRecordMapper;
import com.huike.business.service.ITbBusinessTrackRecordService;
import com.huike.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商机跟进记录Service业务层处理
 * 
 * @author wgl
 * @date 2021-04-28
 */
@Service
public class TbBusinessTrackRecordServiceImpl implements ITbBusinessTrackRecordService {

    @Autowired
    private TbBusinessTrackRecordMapper tbBusinessTrackRecordMapper;

    /**
     * 新增
     * @param
     */
    @Override
    public void insertTbBusinessTrackRecord(BusinessTrackVo businessTrackVo) {
        //set和get方法
        //首先xian new一个对象
        TbBusinessTrackRecord tbBusinessTrackRecord = new TbBusinessTrackRecord();
        //根据数据库依次填入数据,meiyou until工具类好用，until方法详见商机接口
        //由于vo商机跟进记录有一个父类，所以在父类添加一个属性就可以继续使用此方法
        tbBusinessTrackRecord.setRecord(businessTrackVo.getRecord());
        tbBusinessTrackRecord.setBusinessId(businessTrackVo.getBusinessId());
        tbBusinessTrackRecord.setKeyItems(businessTrackVo.getKeyItems());
        tbBusinessTrackRecord.setTrackStatus(businessTrackVo.getTrackStatus());
        tbBusinessTrackRecord.setNextTime(businessTrackVo.getNextTime());
        //全局人
        tbBusinessTrackRecord.setCreateBy(SecurityUtils.getUsername());
        tbBusinessTrackRecordMapper.insertTbBusinessTrackRecord(tbBusinessTrackRecord);
    }


    /**
     * 查询
     * @param id
     * @return
     */
    @Override
    public List<TbBusinessTrackRecord> selectTbBusinessTrackRecord(Long id) {

        List<TbBusinessTrackRecord> records=tbBusinessTrackRecordMapper.selectTbBusinessTrackRecord(id);

        /*return tbBusinessTrackRecordMapper.selectTbBusinessTrackRecord(id);*/
        return records;
    }
}
